package com.ruibang.glass.material.controller.cp;

import com.ruibang.glass.material.domain.req.ChangeGradeReq;
import com.ruibang.glass.material.domain.req.bcp.BcpProductsOutReq;
import com.ruibang.glass.material.domain.req.bcp.ManageBCPOutInReq;
import com.ruibang.glass.material.entity.bcp.MaterialBcpProductsInInfo;
import com.ruibang.glass.material.entity.cp.MaterialCPProductsOut;
import com.ruibang.glass.material.entity.cp.MaterialChangeGrade;
import com.ruibang.glass.material.service.cp.MaterialCPProductsOutService;
import com.ruibang.glass.material.service.cp.MaterialChangeGradeService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 *品级调整 前端控制器
 * </p>
 *
 * @author mameng
 * @since 2024-02-05
 */
@RestController
@RequestMapping("/api/material/cp/change/grade/")
@Api(value = "品级调整", tags = {"品级调整"})
public class MaterialCPChangeGradeController {


    @Autowired
    private MaterialChangeGradeService materialChangeGradeService;

    @PostMapping("/list")
    @ApiOperation(value = "品级调整列表查询", response = ResultBody.class)
    public ResultBody getPageList(@RequestBody ChangeGradeReq bcpProductsOutReq) {
        return ResultBody.success(materialChangeGradeService.getPage(bcpProductsOutReq));
    }

    @PostMapping("/addMaterialChangeGrade")
    @ApiOperation(value = "品级调整列表查询", response = ResultBody.class)
    public ResultBody addMaterialChangeGrade(@RequestBody MaterialChangeGrade materialChangeGrade) {
        materialChangeGradeService.addMaterialChangeGrade(materialChangeGrade);
        return ResultBody.success();
    }

    @GetMapping("/processNotice/{businessId}")
    @ApiOperation(value = "流程处理通知", response = ResultBody.class)
    public ResultBody processNotice(@PathVariable("businessId") String businessId) {
        materialChangeGradeService.processNotice(businessId);
        return ResultBody.success();
    }


    @PostMapping("/updateMaterialChangeGrade")
    @ApiOperation(value = "品级调整列表查询", response = ResultBody.class)
    public ResultBody updateMaterialChangeGrade(@RequestBody MaterialChangeGrade materialChangeGrade) {
        MaterialChangeGrade byId = materialChangeGradeService.getById(materialChangeGrade.getId());
        materialChangeGrade.setApproveStatus(byId.getApproveStatus());
        return ResultBody.success(materialChangeGradeService.updateById(materialChangeGrade));
    }

    @GetMapping("/deleteMaterialChangeGrade/{id}")
    @ApiOperation(value = "删除", response = ResultBody.class)
    public ResultBody deleteMaterialChangeGrade(@PathVariable("id") String id) {
        return ResultBody.success(materialChangeGradeService.removeById(id));
    }

    @GetMapping("/getDetail/{id}")
    @ApiOperation(value = "详情", response = ResultBody.class)
    public ResultBody getDetail(@PathVariable("id") String id) {
        return ResultBody.success(materialChangeGradeService.getById(id));
    }

    @GetMapping("/getDetail")
    @ApiOperation(value = "获取A型架下拉列表", response = ResultBody.class)
    public ResultBody getDetail() {
        return ResultBody.success(materialChangeGradeService.getMaterialContentLotList());
    }




}
